package com.wft.proxy;

public class OrderPorxy implements OrderApi {
    private Order order;

    public OrderPorxy(Order order) {
        this.order = order;
    }

    @Override
    public String getProductName() {
        return order.getProductName();
    }

    @Override
    public int getOrderNum() {
        return order.getOrderNum();
    }

    @Override
    public String getOrderUser() {
        return order.getOrderUser();
    }

    @Override
    public void setProductName(String productName, String user) {
        if (user != null && user.equals(this.getOrderUser())) {
            order.setProductName(productName, user);
        } else {
            System.out.println("setProductName no auth");
        }
    }

    @Override
    public void setOrderNum(int orderNum, String user) {
        if (user != null && user.equals(this.getOrderUser())) {
            order.setOrderNum(orderNum, user);
        } else {
            System.out.println("setOrderNum no auth");
        }
    }

    @Override
    public void setOrderUser(String orderUser, String user) {
        if (user != null && user.equals(this.getOrderUser())) {
            order.setOrderUser(orderUser, user);
        } else {
            System.out.println("setOrderUser no auth");
        }
    }

    @Override
    public String toString() {
        return "Order{" +
                "productName='" + order.getProductName() + '\'' +
                ", orderNum=" + order.getOrderNum() +
                ", orderUser='" + order.getOrderUser() + '\'' +
                '}';
    }
}
